﻿using System;
using System.Runtime.InteropServices;

namespace Padsurface.CoreAudio.MultiMediaStructures
{
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 2)]
    public class WaveFormat
    {
        /// <summary>
        /// Format type
        /// </summary>
        public UInt16 FormatTag;

        /// <summary>
        /// Number of channels in the waveform-audio data.
        /// Mono data uses one channel and stereo data uses two channels.
        /// </summary>
        public UInt16 Channels;

        /// <summary>
        /// Sample rate, in samples per second
        /// </summary>
        public UInt32 SamplesPerSec;

        /// <summary>
        /// Required average data transfer rate, in bytes per second. 
        /// For example, 16-bit stereo at 44.1 kHz has an average data rate of 176,400 bytes per second 
        /// (2 channels — 2 bytes per sample per channel — 44,100 samples per second).
        /// </summary>
        public UInt32 AvgBytesPerSec;

        /// <summary>
        /// Block alignment, in bytes. 
        /// The block alignment is the minimum atomic unit of data. 
        /// For PCM data, the block alignment is the number of bytes used by a single sample, including data for both channels if the data is stereo. 
        /// For example, the block alignment for 16-bit stereo PCM is 4 bytes (2 channels — 2 bytes per sample).
        /// </summary>
        public UInt16 BlockAlign;
    }
}
